package org.ddd.book.infrastructure.book;

import cn.hutool.core.bean.BeanUtil;
import lombok.AllArgsConstructor;
import org.ddd.book.domain.book.entity.BookEntity;
import org.ddd.book.domain.book.repository.IBookRepository;
import org.ddd.book.infrastructure.book.dao.BookMapperService;
import org.ddd.book.infrastructure.book.po.BookPO;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

@Repository
@AllArgsConstructor
public class BookRepositoryMysqlImpl implements IBookRepository {
    private final BookMapperService bookMapperService;

    @Override
    public BookEntity get(Serializable bookId) {
        BookPO bookPO = bookMapperService.getById(bookId);
        BookEntity bookEntity = new BookEntity();
        BeanUtil.copyProperties(bookPO, bookEntity);
        return bookEntity;
    }

    @Override
    public void save(BookEntity book) {
        BookPO bookPO = BeanUtil.copyProperties(book, BookPO.class);
        bookMapperService.save(bookPO);
    }

    @Override
    public void remove(Serializable id) {

    }

    @Override
    public List<BookEntity> bookshelfBookList(Long bookshelfId) {
        return null;
    }
}
